<?php
require_once 'AMClassDefinition.php';
class MClassDefinition extends AMClassDefinition {
	
	/**
	 * Class Definition based on Array
	 * Array structure:
	 * 
	 * $arClass = array("name" => "ClassName", //name of the class
						"path" => null, //path to the file where the class is declared
						"require_once" => true, //use require or include
						"args" => array("arg1", "arg2")); //args has the args necessary to create the object
															if no args, args must be false
	 *
	 * @param array $arDef
	 */
	public function __construct(Array $arDef){
		$this->arDef = $arDef;
		$this->validate();
		
		$this->name = $this->arDef['name'];
		$this->args = $this->arDef['args'];
		$this->path = $this->arDef['path'];
		$this->require_once = $this->arDef['require_once'];
	}
	
	public function validate(){
		if (sizeof($this->arDef)==0) {
			throw new MException('ClassDefinition Array is Empty!');
		}
		
		if(!array_key_exists('name', $this->arDef) &&
		   !array_key_exists('args', $this->arDef) &&
		   !array_key_exists('path', $this->arDef) &&
		   !array_key_exists('require_once', $this->arDef)){
		   	throw new MException('ClassDefinition Array is not VALID!');
		   }
	}
}
?>